////////////////////////////////////////////////////////////////////////////////
// This file is part of the Mist compiler.                                    //
//                                                                            //
// Copyright (C) 2009 The Mist project                                        //
//                                                                            //
// For a list of contributors, see the COMMITTERS file.                       //
//                                                                            //
// The Mist compiler is free software: you can redistribute it and/or modify  //
// it under the terms of the GNU General Public License as published by       //
// the Free Software Foundation, either version 3 of the License, or          //
// (at your option) any later version.                                        //
//                                                                            //
// The Mist compiler is distributed in the hope that it will be useful,       //
// but WITHOUT ANY WARRANTY; without even the implied warranty of             //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              //
// GNU General Public License for more details.                               //
//                                                                            //
// You should have received a copy of the GNU General Public License          //
// in the COPYING file. If not, see <http://www.gnu.org/licenses/>.           //
////////////////////////////////////////////////////////////////////////////////

///
/// \file
/// Contains the list of concrete nodes in the AST, which may be used in several
/// places using the C++ preprocessor macro's, also present in this file.
///

#ifndef NODES_HPP
#define NODES_HPP

////////////////////////////////////////////////////////////////////////////////
// Includes                                                                   //
////////////////////////////////////////////////////////////////////////////////

#include <boost/preprocessor/seq/for_each.hpp>

////////////////////////////////////////////////////////////////////////////////
// Forward Declaration of Abstract Classes                                    //
////////////////////////////////////////////////////////////////////////////////

class Node;
class Expression;
class Statement;
class Declaration;
class Type;

////////////////////////////////////////////////////////////////////////////////
// CONCRETE_NODES                                                             //
////////////////////////////////////////////////////////////////////////////////

/// The list of concrete types of nodes in the AST, ordered alphabetically.
///
#define CONCRETE_NODES \
	(ArrayType)         \
	(AssertionArea)      \
	(BooleanLiteral)      \
	(ChainExpression)      \
	(CompoundStatement)    \
	(CppStatement)         \
	(Declarations)         \
	(ForStatement)         \
	(FunctionCall)         \
	(FunctionDeclaration)  \
	(FunctionType)         \
	(Identifier)           \
	(IfStatement)          \
	(IntegerLiteral)       \
	(NamedType)            \
	(OperatorCall)         \
	(PointerType)          \
	(Reference)            \
	(TypeDeclaration)      \
	(TypeType)             \
	(VariableDeclaration)  \
	(VoidType)             \
	(WhileStatement)

////////////////////////////////////////////////////////////////////////////////
// Possible List Macro's                                                      //
////////////////////////////////////////////////////////////////////////////////

/// Generate a forward declaration of \a elem.
///
#define CONCRETE_NODE_CLASS(r, data, elem) class elem;

/// Generate forward declarations of all \a nodes.
///
#define CLASSES_FROM(nodes) BOOST_PP_SEQ_FOR_EACH(CONCRETE_NODE_CLASS,, nodes)

/// Generate a visitor function prototype for visiting an \a element.
///
#define CONCRETE_NODE_AS_VISIT_FUNCTION(r, data, elem) void visit(wptr<elem>);

/// Generate visitor function prototypes for all \a nodes.
///
#define VISIT_FUNCTIONS_FROM(nodes) BOOST_PP_SEQ_FOR_EACH(CONCRETE_NODE_AS_VISIT_FUNCTION,, nodes)

/// Generate an abstract visitor function prototype for visiting an \a element.
///
#define CONCRETE_NODE_AS_ABSTRACT_VISIT_FUNCTION(r, data, elem) virtual void visit(wptr<elem>) =0;

/// Generate abstract visitor function prototypes for all \a nodes.
///
#define ABSTRACT_VISIT_FUNCTIONS_FROM(nodes) BOOST_PP_SEQ_FOR_EACH(CONCRETE_NODE_AS_ABSTRACT_VISIT_FUNCTION,, nodes)

/// Generate a virtual visitor function prototype for visiting an \a element.
///
#define CONCRETE_NODE_AS_VIRTUAL_VISIT_FUNCTION(r, data, elem) virtual void visit(wptr<elem>);

/// Generate virtual visitor function prototypes for all \a nodes.
///
#define VIRTUAL_VISIT_FUNCTIONS_FROM(nodes) BOOST_PP_SEQ_FOR_EACH(CONCRETE_NODE_AS_VIRTUAL_VISIT_FUNCTION,, nodes)

#endif // NODES_HPP
